<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/maa.tld" prefix="m" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setLocale value="${language}"/>
<fmt:bundle basename="messages" prefix="userselfupdate.">

    <html>

    <head>
        <title><fmt:message key="title"/></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width">
        <link rel="stylesheet" href="${pageContext.servletContext.contextPath}/static/bootstrap/css/bootstrap.css">
        <link href="${pageContext.request.contextPath}/css/user-self-update.css" rel="stylesheet">
        <link rel="shortcut icon" href="${pageContext.servletContext.contextPath}/static/yin.ico">
        <script type="text/javascript"
                src="${pageContext.servletContext.contextPath}/static/bootstrap/js/bootstrap.min.js"></script>
        <style type="text/css">

        </style>
    </head>

    <div class="navbar-wrapper">
        <div class="container-fluid">
            <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
                <div class="container">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle" data-toggle="collapse"
                                data-target=".navbar-collapse">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="/maa/do?action=main"> <img
                                src="${pageContext.servletContext.contextPath}/static/ics.png"/>Silver Dragon</a>
                    </div>
                    <div class="navbar-collapse collapse">
                        <ul class="nav navbar-nav navbar-right">
                            <li><a><strong><fmt:message key="greet"/> ${user.name} ${user.surname}!</strong></a></li>
                            <m:language/>
                            <li>
                                <form action="/maa/do" method="post">
                                    <input type="hidden" name="action" value="logout">
                                    <input class="btn btn-default navig" type="submit"
                                           value="<fmt:message key="logout"/>"/>
                                </form>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-3 col-md-2 sidebar">
                <ul class="nav nav-sidebar">
                    <li class="active"><a href="/maa/do?action=account"><fmt:message key="overview"/></a></li>
                    <li><a href="/maa/do?action=my-subscriptions"><fmt:message key="mysubs"/></a></li>
                    <li><a href="/maa/do?action=user-self-update"><fmt:message key="edit"/></a></li>
                    <c:if test="${not empty user and user.role == 'MENTOR'}">
                        <li><a href="/maa/do?action=main"><fmt:message key="mycourses"/></a></li>
                    </c:if>
                </ul>
            </div>
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <h1 class="page-header"><fmt:message key="title"/></h1>

                <div class="container">
                    <form class="form-signin" action="/maa/do" method="post">
                        <h2 class="form-signin-heading"><fmt:message key="edit"/></h2>

                        <c:if test="${not empty incorrect_email}">
                            <%=request.getAttribute("incorrect_email")%>
                        </c:if>
                        <c:if test="${not empty incorrect_name}">
                            <%=request.getAttribute("incorrect_name")%>
                        </c:if>
                        <c:if test="${not empty incorrect_surname}">
                            <%=request.getAttribute("incorrect_surname")%>
                        </c:if>
                        <c:if test="${not empty incorrect_gender}">
                            <%=request.getAttribute("incorrect_gender")%>
                        </c:if>
                        <c:if test="${not empty incorrect_birthdate}">
                            <%=request.getAttribute("incorrect_birthdate")%>
                        </c:if>
                        <c:if test="${not empty invalid_password}">
                            <%=request.getAttribute("invalid_password")%>
                        </c:if>
                        <c:if test="${not empty incorrect_password}">
                            <%=request.getAttribute("incorrect_password")%>
                        </c:if>
                        <c:if test="${not empty invalid_new_password}">
                            <%=request.getAttribute("invalid_password")%>
                        </c:if>
                        <c:if test="${not empty unmatching_passwords}">
                            <%=request.getAttribute("unmatching_passwords")%>
                        </c:if>

                        <p><fmt:message key="email"/></p>
                        <input type="text" name="email" class="form-control input-lg"
                               placeholder="example@example.com" value="${user.email}">

                        <p><fmt:message key="name"/></p>
                        <input type="text" name="name" class="form-control" value="${user.name}">

                        <p><fmt:message key="surname"/></p>
                        <input type="text" name="surname" class="form-control" value="${user.surname}">

                        <p><fmt:message key="gender"/></p>
                        <c:choose>
                            <c:when test="${user.gender eq 'MALE'}">
                                <select id="gender" name="gender" class="form-control">
                                    <option value="male" selected><fmt:message key="male"/></option>
                                    <option value="female"><fmt:message key="female"/></option>
                                </select>
                            </c:when>
                            <c:otherwise>
                                <select id="gender" name="gender" class="form-control">
                                    <option value="male"><fmt:message key="male"/></option>
                                    <option value="female" selected><fmt:message key="female"/></option>
                                </select>
                            </c:otherwise>
                        </c:choose>

                        <p><fmt:message key="birthdate"/></p>
                        <input type="date" name="birthdate" class="form-control" value="${user.birthdate}">

                        <p><fmt:message key="curpas"/></p>
                        <input type="password" name="current-password" class="form-control">

                        <p><fmt:message key="newpas"/></p>
                        <input type="password" name="new-password" class="form-control">

                        <p><fmt:message key="confirmnewpas"/></p>
                        <input type="password" name="confirm-new-password" class="form-control">

                        <button class="btn btn-lg btn-block" type="submit"><fmt:message key="update"/></button>
                        <input type="hidden" name="action" value="edit-profile">
                        <input type="hidden" name="uuid" value=${user.uuid}/>
                    </form>
                    <form class="form-signin" action="/maa/do" method="get">
                        <button class="btn btn-lg btn-block" type="submit"><fmt:message key="return"/></button>
                        <input type="hidden" name="action" value="account">
                    </form>
                </div>
            </div>
        </div>
    </div>
    </body>
    </html>

</fmt:bundle>

